package com.manaka.servlet;

import com.manaka.service.MaintainService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * 自动回复Servlet
 *
 * @author Manaka
 * @date 2018-09-09 12:23
 */
public class AutoReplyServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html;charset=utf-8");

        MaintainService service = new MaintainService();

        PrintWriter out = resp.getWriter();
        out.write(service.autoReply(req.getParameter("content")));
        out.flush();
        out.close();
    }
}
